import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
import editorware from '../components/tool/utils/editorMiddleware'
export default new Vuex.Store({
    state: {
        coverage: false, // 图层对话框显示状态
        drawing: {
            isShow: false,
            type: ''
        }, // 标绘对话框显示状态
        measure: {
            isShow: false,
            type: 'measure'
        }, // 图上量算和空间分析状态
        contextMenu: {
            isShow: false,
            X: 0,
            Y: 0,
            type1: '',
            type2: '',
            time: 0
        },
        singleProperty: false, // 单个属性框,
        menuIcon: false, // 图标库
        printMapAnImage: false, // 打印地图
        editMovePoint: {}, //绘标编辑点
        dialogVisible: false, // 弹框
        nodeId: '', //右键选中node
        // printMap: false // 打印地图
        // tif偏移设置
        isSkewingAmend: false,
        amendName: '',
        amendIdP: '',
        // 瓦片图层便宜设置
        isTileAdjustment: false,
        tileAdjustmentData: ''
    },
    mutations: {
        // 设置图层偏移对话框
        setamendId: (state, self) => {
            state.amendId = self
        },
        setamendName: (state, self) => {
            state.amendName = self
        },
        setSkewingAmend: (state, self) => {
            if (!self) {
                editorware.rightClickData = ''
            }
            state.isSkewingAmend = self
        },
        // 瓦片图层便宜设置
        setTileAdjustment: (state, self) => {
            if (!self) {
                editorware.rightClickData = ''
            }
            state.isTileAdjustment = self
        },
        setTileAdjustmentData: (state, self) => {
            state.tileAdjustmentData = self
        },
        showDialog: (state, self) => {
            if (self.isShow == true) {
                state.dialogVisible = true
            } else {
                state.dialogVisible = false
            }
        },
        // 设置图层对话框显示状态
        setCoverage: (state, self) => {
            state.coverage = !state.coverage
        },
        // 设置标绘对话框显示状态
        setDrawing: (state, self) => {
            if (self) {
                state.drawing.isShow = true
            } else {
                state.drawing.isShow = false
            }

            state.drawing.type = self
        },
        // 设置图上量算和空间分析状态
        setMeasure: (state, self) => {
            if (self == 'off') {
                state.measure.isShow = false
            } else {
                state.measure.isShow = true
            }
            if (self) {
                state.measure.type = self
            } else {
                state.measure.type = ''
            }
        },
        // 设置右键菜单
        setContextMenu: (state, self) => {
            state.contextMenu.isShow = self.isShow
            state.contextMenu.X = self.X ? self.X : 0
            state.contextMenu.Y = self.Y ? self.Y : 0
            state.contextMenu.type1 = self.type1 ? self.type1 : ''
            state.contextMenu.type2 = self.type2 ? self.type2 : ''
            state.contextMenu.time = self.time ? self.time : ''
        },
        // 设置单个属性框显示状态
        setSingleProperty: (state, self) => {
            if (self != undefined) {
                state.singleProperty = self
            } else {
                state.singleProperty = !state.singleProperty
            }
            // console.log(state.singleProperty)
            if (!state.singleProperty) {
                // console.log(editorware.rightClickData)
                if (editorware.rightClickData && editorware.rightClickData.id && editorware.rightClickData != 'tif') {
                    editorware.rightClickData.stopEditing()
                }
            } else {
                // state.coverage = false
            }
        },
        // 设置图标库显示状态
        setMenuIcon: (state, self) => {
            state.menuIcon = !state.menuIcon
        },
        // 设置打印地图组件显示状态
        setPrintMap: (state, self) => {
            state.printMapAnImage = !state.printMapAnImage
        }
        // setPrintMap: (state, self) => {
        //     state.printMap = !state.printMap
        // }
    },
    actions: {},
    modules: {}
})
